package com.qyer.search.db;

import com.qyer.commons.persistence.AbstractDBResourceManager;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * User: Z J Wu Date: 2015/03/23 Time: 10:27 Package: com.qyer.dsp.utils
 */
public class DMDBResourceManager extends AbstractDBResourceManager {

  private static final Logger LOGGER = LoggerFactory.getLogger(DMDBResourceManager.class);

  private static class InnerHolder {

    private static final DMDBResourceManager INSTANCE = new DMDBResourceManager();
  }

  public static DMDBResourceManager getInstance() {
    return InnerHolder.INSTANCE;
  }

  private DMDBResourceManager() {
    CompositeConfiguration c = new CompositeConfiguration();
    c.addConfiguration(new SystemConfiguration());
    String file = c.getString("search.db.dm.properties.location", "/etc/search.db.dm.properties");
    try {
      initByLocalConf(file);
    } catch (Exception e) {
      LOGGER.error("Cannot load local config file(" + file + ").", e);
    }
  }
}
